<template>
	<div class="main">
		<van-field label="管理制度名称" v-model="data.TemplateName" name="title" readonly>
		</van-field>

		<van-field label="模板类别" v-model="data.TemplateTypeName" name="title" readonly>
		</van-field>

		<van-field label="是否必须上传" v-model="data.IsMustInputName" name="title" readonly>
		</van-field>

		<van-field label="模板说明" v-model="data.TemplateRemarks" name="title" readonly>
		</van-field>

		<FileUpload
        @CallBack="_fileUploadCb"
        :attachs="data.TemplateAttachs"
        :labelName="'模板文件'"
        :allowEdit="false"
      />

		<van-field
			label="附件记录备注"
			rows="3"
			autosize
			type="textarea"
			v-model="data.RecordRemark"
		>
		</van-field>


		<FileUpload
        @CallBack="fileUploadCb"
        :Record="data.Record"
        :labelName="'上传附件'"
      />

		<div class="bottom_submit">
			<van-button type="primary" @click="_submit(10)" > 保存 </van-button>
		</div>

	</div>
</template>

<script>
import FileListReadOnly from "../../../components/Attach/FileListReadOnlyYat.vue";
import FileUpload from "../../../components/Attach/FileUploadYat.vue";
export default {
	components: { FileListReadOnly, FileUpload },
	data() {
		return {
			id: this.$route.query.id,
			templateId: this.$route.query.templateId,
			data: {
				
			},
		}
	},
	beforeMount () {
		this.data = []

		
		//store.commit('updateTitle', title)
	},
	created() {
		
		this.getDetail();
	},
	activated() {},
	methods: {
		getDetail() {
			let params = { id: this.id, templateId: this.templateId };
			this.$axios
				.get('/YatManagementDocsApi/UploadOrView', { params: params })
				.then((res) => {
				this.data = res.data;
				if (this.data.IsMustInput == true) {
					this.data.IsMustInputName = '是'
				} else {
					this.data.IsMustInputName = '否'
				}
				});
		},
		_fileUploadCb(attachs) {
			this.data.Attachs = attachs;
		},
		fileUploadCb(Record) {
			this.data.Record = Record;
		},
		// 保存
		_submit(states) {
		this.$axios
            // POST /api/YatManagementDocsApi/RecordPost
            .post('/YatManagementDocsApi/RecordPost', this.data)
            .then((res) => {
              this.$toast.success("保存成功");
              this.$router.push("/YatManagementDocs");
            });
		},
	},
}
</script>

<style lang="less" scoped>
.bottom_submit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 15px;
  box-sizing: border-box;
  .van-button {
    width: 100%;
    height: 35px;
	
  }
}
</style>
